package com.study.talk.data.model;


import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;

import com.study.talk.data.model.vo.UserInfoVo;
import com.study.common.annotation.Desc;

import java.io.Serializable;


/**
 * @author thor
 * @since 2023-12-18
 */
@Entity(tableName = "user_info")
public class UserInfo implements Serializable {


    @PrimaryKey
    @ColumnInfo(name = "id")
    @Desc("用户id")
    private Integer id;

    @ColumnInfo(name = "username")
    @Desc("用户名")
    private String username;

    @ColumnInfo(name = "nick_name")
    @Desc("用户昵称")
    private String nickName;

    @ColumnInfo(name = "gender")
    @Desc("用户性别")
    private Integer gender;

    @ColumnInfo(name = "email")
    @Desc("用户邮箱")
    private String email;

    @ColumnInfo(name = "avatar")
    @Desc("用户头像地址")
    private String avatar;

    @ColumnInfo(name = "birth")
    @Desc("用户生日")
    private String birth;

    @ColumnInfo(name = "address")
    @Desc("用户住址")
    private String address;

    @ColumnInfo(name = "introduce")
    @Desc("用户简介")
    private String introduce;

    @ColumnInfo(name = "bg_img")
    @Desc("用户主页背景图片地址")
    private String bgImg;

    @ColumnInfo(name = "like_count")
    @Desc("用户点赞数")
    private Integer likeCount;

    @ColumnInfo(name = "phone")
    @Desc("用户手机号")
    private String phone;

    @ColumnInfo(name = "create_time")
    @Desc("创建时间")
    private String createTime;

    @Ignore
    public UserInfo(UserInfoVo user) {
        this.id = user.getUserId();
        this.username = user.getUsername();
        this.email = user.getEmail();
        this.nickName = user.getNickName();
        this.phone = user.getPhone();
        this.gender = user.getGender();
        this.introduce = user.getIntroduce();
        this.likeCount = 0;
        this.avatar = user.getAvatar();
        this.birth = user.getBirth();
        this.address = user.getAddress();
        this.bgImg = user.getBgImg();
    }

    public UserInfo() {
    }

    @Ignore
    public UserInfo(Integer id, String username, String nickName, Integer gender, String email, String avatar, String birth, String address, String introduce, String bgImg, Integer likeCount, String phone, String createTime) {
        this.id = id;
        this.username = username;
        this.nickName = nickName;
        this.gender = gender;
        this.email = email;
        this.avatar = avatar;
        this.birth = birth;
        this.address = address;
        this.introduce = introduce;
        this.bgImg = bgImg;
        this.likeCount = likeCount;
        this.phone = phone;
        this.createTime = createTime.replaceAll("T", " ");
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public Integer getGender() {
        return gender;
    }

    public void setGender(Integer gender) {
        this.gender = gender;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getBirth() {
        return birth;
    }

    public void setBirth(String birth) {
        this.birth = birth;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getIntroduce() {
        return introduce;
    }

    public void setIntroduce(String introduce) {
        this.introduce = introduce;
    }

    public String getBgImg() {
        return bgImg;
    }

    public void setBgImg(String bgImg) {
        this.bgImg = bgImg;
    }

    public Integer getLikeCount() {
        return likeCount;
    }

    public void setLikeCount(Integer likeCount) {
        this.likeCount = likeCount;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime.replaceAll("T", " ");
    }
}
